package PTA.javaB;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.DataFormatException;

public class ex26 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int num = sc.nextInt();
       //创建时间转换对象
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //创建集合对象
        ArrayList<Date> list =new ArrayList<>();
int count=0;
for(int i=0;i<num;i++){
    String time = sc.next();
    try{
        Date date = sdf.parse(time);
        list.add(date);
    }catch(ParseException e){
        System.out.println("Line "+i+" error. "+e.getMessage());
count++;

    }
}
        System.out.println("Totally "+count+" lines error.");
Collections.sort(list);
for(Date s:list){

    SimpleDateFormat sdf1 = new SimpleDateFormat("MM dd, yyyy");
    String timedate=sdf1.format(s);
    System.out.println(timedate);
}
    }
}
